//
//  BaseWkWebViewContoller.swift
//  EasyTrademarkRegqurySearch
//
//  Created by 伊伊 on 2024/3/5.
//

import UIKit
import WebKit
class BaseWkWebViewContoller: BaseViewController,WKNavigationDelegate{
    @objc var urlString:String = ""
      
      override func viewDidLoad() {
          super.viewDidLoad()
           let webView = WKWebView()
          webView.navigationDelegate = self
          self.view .addSubview(webView)
          webView.snp.makeConstraints { make in
              make.edges.equalToSuperview()
          }
          let  urlString = self.urlString.stringPercentEncoding(characters: "")
          let url = URL(string: urlString)!
          webView.load(URLRequest(url: url))
//          
//          let btn = UIButton()
//          //btn.backgroundColor = .red
//          btn.setImage(UIImage(named: "nav_back"), for: .normal)
//          btn.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
//          btn.contentHorizontalAlignment = .left
//          let buttonItem = UIBarButtonItem(customView: btn)
//          self.navigationItem.leftBarButtonItem = buttonItem;
//          btn.addTarget(self, action: #selector(backpage), for: .touchUpInside)
          
      }
      
      func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
          EasyProgressHud.show()
      }
      func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
          EasyProgressHud.dismiss()
      }
      
      func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
          EasyProgressHud.dismiss()
      }
      @objc func backpage(){
          self.navigationController?.popViewController(animated: true)
      }

}
